package com.sitanyun.merchant.guide.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sitanyun.merchant.guide.R;
import com.sitanyun.merchant.guide.bean.UnitreateBean;

/**
 * Created by jzl
 * on 2022/1/18.
 * 消息适配器
 */
public class UntreatedAdapter extends BaseQuickAdapter<UnitreateBean.DataBean.RecordsBean, BaseViewHolder> {

    public UntreatedAdapter(Context context) {
        super(R.layout.msg_item);
        this.mContext = context;
    }
    // 用户行为 浏览 留言 要求回电 同屏讲解 分享
    // enum('BROWSE','MESSAGE','CALL','MEETING','SHARE')
    @Override
    protected void convert(BaseViewHolder helper, UnitreateBean.DataBean.RecordsBean item) {
        helper.addOnClickListener(R.id.ll_layout);
        String userposter = "";
        TextView img_readflag = helper.getView(R.id.img_readflag);
        if (item.getReadFlag()==0){
            img_readflag.setVisibility(View.VISIBLE);
        }else {
            img_readflag.setVisibility(View.GONE);
        }
       if (item.getBizId()==0){

           if (item.getBehavior().getBehavior().equals("BROWSE")){
               userposter="正在浏览";
               helper.setText(R.id.cname,"微信昵称：");
               helper.setText(R.id.cmsg,"消息内容：");
               helper.setText(R.id.ctime,"进入时间：");
               helper.setText(R.id.uni_msg,"正在浏览场景 "+item.getBehavior().getSceneName());
               String  startTime = item.getBehavior().getStartTime();
               String  substring = startTime.substring(11, startTime.length());
               helper.setText(R.id.uni_times,""+substring);
           }else if (item.getBehavior().getBehavior().equals("MESSAGE")){
               userposter="留言待处理";
               helper.setText(R.id.cname,"微信昵称：");
               helper.setText(R.id.cmsg,"留言内容：");
               helper.setText(R.id.ctime,"留言时间：");
               helper.setText(R.id.uni_msg,""+item.getBehavior().getMessage());
               String  sendTime = item.getSendTime();
               String  substring = sendTime.substring(11, sendTime.length());
               helper.setText(R.id.uni_times,""+substring);
           }else if (item.getBehavior().getBehavior().equals("CALL")){
               userposter="用户已预留号码，要求回电";
               helper.setText(R.id.cname,"微信昵称：");
               helper.setText(R.id.cmsg,"预留电话：");
               helper.setText(R.id.ctime,"预留时间：");
               helper.setText(R.id.uni_msg,item.getBehavior().getCPhone());
               String  sendTime = item.getSendTime();
               String  substring = sendTime.substring(11, sendTime.length());
               helper.setText(R.id.uni_times,""+substring);
           }
           else if (item.getBehavior().getBehavior().equals("MEETING")){
               //未处理
               if (item.getBehavior().isEnd()==false){
                   userposter="有同屏讲解要求未处理";
                   helper.setText(R.id.cname,"微信昵称：");
                   helper.setText(R.id.cmsg,"待处理问题：");
                   helper.setText(R.id.ctime,"申请时间：");
                   helper.setText(R.id.uni_msg,"用户发起同屏讲解，未处理");
                   String  startTime = item.getBehavior().getStartTime();
                   String  substring = startTime.substring(11, startTime.length());
                   helper.setText(R.id.uni_times,""+substring);

                   //拒绝状态
               }else if (item.getBehavior().isReject()==true){
                   userposter="用户拒绝同屏讲解";
                   helper.setText(R.id.cname,"微信昵称：");
                   helper.setText(R.id.cmsg,"待处理问题：");
                   helper.setText(R.id.ctime,"同屏时间：");

                   helper.setText(R.id.uni_msg,"用户拒绝同屏讲解");
                   String  startTime = item.getBehavior().getStartTime();
                   String  start = startTime.substring(11, startTime.length());
                   helper.setText(R.id.uni_times,""+start);

               } else {
                   //已处理
                   userposter="用户结束同屏讲解";
                   helper.setText(R.id.cname,"微信昵称：");
                   helper.setText(R.id.cmsg,"待处理问题：");
                   helper.setText(R.id.ctime,"同屏时段：");

                   String  startTime = item.getBehavior().getStartTime();
                   String  start = startTime.substring(11, startTime.length());
                   String  sendTime = item.getSendTime();
                   String  end = sendTime.substring(11, sendTime.length());
                   helper.setText(R.id.uni_msg,"用户结束同屏讲解");
                   helper.setText(R.id.uni_times,start+" 到 "+end);
               }

           }
           else if (item.getBehavior().getBehavior().equals("SHARE")){
               userposter="分享";
//                helper.setText(R.id.cname,"");
//                helper.setText(R.id.cmsg,"");
//                helper.setText(R.id.ctime,"");
           }

           helper.setText(R.id.uni_time,item.getCreateTime())
                   .setText(R.id.uni_title,item.getBehavior().getStoreName()+"-"+item.getBehavior().getCName()+" "+userposter);
           helper.setText(R.id.uni_username,item.getBehavior().getCName());


       }else {
           //1 返利
           if (item.getBehavior()==null){
               return;
           }
           if (item.getBehavior().getType().equals("1")){
               helper.setText(R.id.cname,"订单用户：");
               helper.setText(R.id.cmsg, "消息内容：");
               helper.setText(R.id.ctime,"订单时间：");
                 }else {
               //0下单
               helper.setText(R.id.cname,"微信昵称：");
               helper.setText(R.id.cmsg,"消息内容：");
               helper.setText(R.id.ctime,"订单时间：");
           }
           helper .setText(R.id.uni_title,item.getBehavior().getTitle());
           helper .setText(R.id.uni_username,item.getBehavior().getName());
           helper .setText(R.id.uni_msg,item.getBehavior().getContent());
           helper .setText(R.id.uni_times,item.getBehavior().getOrderTime());

       }




    }
}